/**
 Copyright will be fixed soon.
 Author: Hiroshi Ota.
 $Date: $
 $Revision: $
*/

#ifndef _BF_BEHAVIOR_CONTROL_H_
#define _BF_BEHAVIOR_CONTROL_H_

#include "IBFBehaviorControl.h"
#include "BFRunningStateApp.h"

class BFBehaviorControl :
	public IBFBehaviorControl
{
public:
	BFBehaviorControl(
		Motor* drive, Motor* stairing,
		LightSensor* light,
#ifndef _NO_USE_BF_TOUCH_SENSOR
		TouchSensor* touch,
#endif
		IBFUI* ui, IBFLog* log);
	~BFBehaviorControl(void);

	void registInitApp(IBFStateApp* app) { initApp = app; }
	void registRunningApp(BFRunningStateApp* app) { runApp = app; }
	void registTermApp(IBFStateApp* app) { termApp = app; }

	void registState(BFState* state);
	void updateState(BFState::SystemState newState);
	BFState* getState() { return currentState; }
	BFArgorithmContainer* getArgorithmContainer() { return &argorithmContainer; }

	Motor* getDriveMotor() { return driveMotor; }
	Motor* getStairingMotor() { return stairingMotor; }
	LightSensor* getLightSensor() { return lightSensor; }
#ifndef _NO_USE_BF_TOUCH_SENSOR
	TouchSensor* getTouchSensor() { return touchSensor; }
#endif

	IBFUI* getUI() { return uiModule; }
	IBFLog* getLog() { return logModule; }

	int start();

protected:
	BFState* currentState;
	IBFStateApp* initApp;
	BFRunningStateApp* runApp;
	IBFStateApp* termApp;
	BFArgorithmContainer argorithmContainer;
	Motor* driveMotor;
	Motor* stairingMotor;
	LightSensor* lightSensor;
#ifndef _NO_USE_BF_TOUCH_SENSOR
	TouchSensor* touchSensor;
#endif
	IBFUI* uiModule;
	IBFLog* logModule;
};

#endif // _BF_BEHAVIOR_CONTROL_H_
